package com.project.weimi.activity;

import com.project.weimi.R;
import com.project.weimi.utils.SetClickListener;
import com.project.weimi.widget.ToastMessage;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

/**
 * 账户与安全Activity
 * @author Administrator
 *
 */
public class AccountSafetyActivity extends BaseActivity{

	private RelativeLayout rl_accountSafe_phone,rl_accountSafe_pwd;
	private Button btn_bindQQ,btn_bindWeibo,btn_bindWeixin;
	
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentViewWithBar(R.layout.activity_account_safety, "账号与安全");
		
		initView();
		
		
	}
	
	private void initView(){
		rl_accountSafe_phone = (RelativeLayout)findViewById(R.id.rl_accountSafe_phone);
		rl_accountSafe_pwd = (RelativeLayout)findViewById(R.id.rl_accountSafe_pwd);
		btn_bindQQ = (Button)findViewById(R.id.btn_bindQQ);
		btn_bindWeibo = (Button)findViewById(R.id.btn_bindWeibo);
		btn_bindWeixin = (Button)findViewById(R.id.btn_bindWeixin);
		
		// 监听
		SetClickListener.setClickListener(listener, rl_accountSafe_phone,rl_accountSafe_pwd,
				btn_bindQQ,btn_bindWeibo,btn_bindWeixin);
		
	}
	
	private OnClickListener listener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			Intent intent = null;
			switch (v.getId()) {
			case R.id.rl_accountSafe_phone:
				intent = new Intent(AccountSafetyActivity.this,BindPhoneActivity.class);
				startActivity(intent);
				break;
			case R.id.rl_accountSafe_pwd:
				intent = new Intent(AccountSafetyActivity.this,SecretSetActivity.class);
				startActivity(intent);
				break;
			case R.id.btn_bindQQ:
				ToastMessage.showMyToast(AccountSafetyActivity.this, "跳转到QQ登录页面");
				break;
			case R.id.btn_bindWeibo:
				bindWeiboDialog();
				break;
			case R.id.btn_bindWeixin:
				ToastMessage.showMyToast(AccountSafetyActivity.this, "跳转到微信登录页面");
				break;
			default:
				break;
			}
			
		}
	};
	
	// 绑定微博对话框
	private void bindWeiboDialog(){
		View view = LayoutInflater.from(AccountSafetyActivity.this).inflate(R.layout.dialog_bind_weibo, null);
		TextView tv_cancel = (TextView)view.findViewById(R.id.tv_cancel);
		TextView tv_ok = (TextView)view.findViewById(R.id.tv_ok);
		final AlertDialog dialog = new AlertDialog.Builder(AccountSafetyActivity.this).setView(view).create();
		dialog.show();	
		tv_cancel.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dialog.dismiss();
			}
		});
		
		tv_ok.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				dialog.dismiss();
				ToastMessage.showMyToast(AccountSafetyActivity.this, "跳转到微博登录页面");
			}
		});
	}
	
	
	@Override
	void setStatusBar(int statusBarColorRes) {
		super.setStatusBar(R.color.transparent_3);
	}
	
	
}
